unit InvcRpt;

interface

uses Windows, SysUtils, Messages, Classes, Graphics, Controls,
  StdCtrls, ExtCtrls, Forms, Quickrpt, QRCtrls, patterns;

type
  TInvoiceByOrderNoReport = class(TQuickRep)
    procedure InvoiceByOrderNoReportBeforePrint(Sender: TCustomQuickRep;
      var PrintReport: Boolean);
  private
  public
  end;

  TControllerInvoiceReport = class(TController)
  protected
    procedure DoCommand(Command: string; const args: string=''); override;
  end;

var
  InvoiceByOrderNoReport: TInvoiceByOrderNoReport;

implementation

uses DataMod, commandlist, PickInvc;

{$R *.DFM}

procedure TInvoiceByOrderNoReport.InvoiceByOrderNoReportBeforePrint(
  Sender: TCustomQuickRep; var PrintReport: Boolean);
begin
  Sender.AllDataSets.Add(TMastData.getInstance.Cust);
  Sender.AllDataSets.Add(TMastData.getInstance.Orders);
end;

procedure TControllerInvoiceReport.DoCommand(Command: string; const args: string='');
begin
  if command = CMD_RPT_INVOICE then
  begin
    with TPickOrderNoDlg.Create(nil) do
    begin
      if ShowModal = mrOk then
        if Lowercase(args) = 'preview' then
          InvoiceByOrderNoReport.Preview
        else
          InvoiceByOrderNoReport.Print;
      free;
    end;
  end;
end;

{
initialization
  ControlCenter.RegController(TControllerInvoiceReport.Create);
  InvoiceByOrderNoReport := TInvoiceByOrderNoReport.create(application);
}

end.

